package com.srit.base.bean;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description 分页
 */
public class Page {
	private int pageNum = 0;// 当前页数
	private int pageSize = DEFAULT_PAGESIZE;
	private int totalPage = 0;// 总页数
	private int totalNum = 0;// 数据总数
	private Object sp;// 查询条件 searchParam缩写
	private List list;// 返回的内容
	private Map<String, Object> result = new HashMap<String, Object>();// map保存
	private static final int DEFAULT_PAGESIZE = 20;// 每页显示条数
	private int start;// sql中开始
	private int end;// sql中结束
	private int[] pageSizeArray = { 20, 40, 60, 100 };

	public int getPageNum() {
		return pageNum;
	}

	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getTotalNum() {
		return totalNum;
	}

	public void setTotalNum(int totalNum) {
		this.totalNum = totalNum;
	}

	public List getList() {
		return list;
	}

	public void setList(List list) {
		this.list = list;
	}

	public Object getSp() {
		return sp;
	}

	public void setSp(Object sp) {
		this.sp = sp;
	}

	public int getTotalPage() {
		BigDecimal bTotalNum = new BigDecimal(totalNum);
		BigDecimal bPageSize = new BigDecimal(pageSize);
		return bTotalNum.divide(bPageSize, BigDecimal.ROUND_CEILING).intValue();
	}

	public int getStart() {
		return pageNum * pageSize;
	}

	public int getEnd() {
		return (pageNum + 1) * pageSize;
	}

	public Map<String, Object> getResult() {
		return result;
	}

	public void putInResult(Object object) {
		// 将返回页面数据塞入result

	}

	public int[] getPageSizeArray() {
		return pageSizeArray;
	}

	public void setPageSizeArray(int[] pageSizeArray) {
		this.pageSizeArray = pageSizeArray;
	}

}
